home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr49 / 289_01.zip / DUMPTREE.C < prev    next >
Text File  |  1993-04-26  |  2KB  |  66 lines

  1. /*
  2. Dump entire move tree (for debugging)
  3. */
  4.  
  5. #include <stdio.h>
  6. #include "othello.h"
  7.  
  8. static key_type dumptree_sub(key_type key, int indent);
  9.  
  10. void
  11. dumptree(key_type key)
  12. {
  13.    dumptree_sub(key, 0);
  14.    fprintf(stdprn, "\r\n\r\n");
  15.    fflush(stdprn);
  16. }
  17.  
  18. static key_type
  19. dumptree_sub(key_type key, int indent)
  20. {
  21.    struct limb_struct far *limb_ptr;
  22.    move_type move;
  23.    struct board_struct dummy_board;
  24.  
  25.    limb_ptr = db_retrieve_limb(key);
  26.  
  27.    /*
  28.       Output information about the limb
  29.       key    move  score sibling child
  30.       00000 . . A1 -32768 00000 00000
  31.       65535 b x H8  32767 65535 65535
  32.    */
  33.    if (limb_ptr == NULL) {
  34.       fprintf(stdprn, "%*s %5d ***** ERROR: limb *****\r\n",
  35.          indent * 3, "",
  36.          key);
  37.       return (NO_KEY);
  38.    }
  39.    else {
  40.       move = limb_ptr->move;
  41.  
  42.       fprintf(stdprn, "%*s %5d %c %c %c%c %6d %5d %5d\r\n",
  43.          indent * 3, "",
  44.          key,
  45.          move & BOARD_MASK ? 'b' : '.',
  46.          move & NO_MOVE_MASK ? 'x' : '.',
  47.          GET_ROW(move) + 'A',
  48.          GET_COL(move) + '1',
  49.          limb_ptr->score,
  50.          limb_ptr->sibling_key,
  51.          limb_ptr->bc.child_key);
  52.  
  53.       if (move & BOARD_MASK) {
  54.          if (db_retrieve_board(limb_ptr->bc.board_key, &dummy_board)) {
  55.             fprintf(stdprn, "%*s ^^^^^ ***** ERROR: board *****\r\n",
  56.                indent * 3, "");
  57.          }
  58.       }
  59.       else {
  60.          for (key = limb_ptr->bc.child_key; key != NO_KEY;
  61.             key = dumptree_sub(key, indent + 1))  ;
  62.       }
  63.       return (limb_ptr->sibling_key);
  64.    }
  65. }
  66.